Introduction to GitHub

Brief introduction using GitHub Desktop

Data Analytics Unit

Before we start

Git

  • Free and open source distributed version control system.
  • Multiple features:
    • Track changes to your files over time.
    • Reliable and secure way to collaborate with multiple developers.
    • Git allows you to work offline and then synchronize your changes when you’re connected.
    • Stores your project’s history as a series of snapshots or commits.
    • Enables branching and merging, allowing for parallel development and experimentation.
    • It provides tools for resolving conflicts when multiple people modify the same file simultaneously.

Github

  • Web-based platform that uses Git for version control.
  • One of the largest online communities for developers.
  • Complementary features:
    • It provides a centralized location for hosting and collaborating on Git repositories.
    • It offers a user-friendly interface to manage Git repositories and track changes.
    • Introduces forks and pull requests.
    • It provides features for issue tracking, project management, commenting, issues submission, and code review.
    • GitHub Desktop available.

Do I need Github?

  • No, you don’t.
  • Git is already installed in your computer.
  • For example:
    • git status
    • git pull
    • git log

Repos

  • A repository is a container that holds all the files, directories, and the history of changes for a project.
  • Root folder of the project.
  • How do we set up a repo?

  • Fill the available options

  • Clone the repo in your local machine using GitHub Desktop

Collaborating

  • You can add collaborators to your project following these steps:
    • Go to your repository’s website
    • Click on the Settings tab
    • Click on the Collaborators entry located on the left-side panel
    • Authenticate yourself
    • Click on the Add people button
    • Search and add collaborators



Commiting and Pushing

  • A commit saves a snapshot of your project’s state at a specific point in time.
  • Commits are saved in the git folder.
  • You can restore your projects to a specific commit in time.
  • Commits allow you to track and manage the process.
  • A push is the action of sending your local commits to a remote repository (GitHub).
  • How do we publish changes?
  • Make sure your local version of the repository is updated by FETCHING any potential PULL.

  • Select, unselect or ignore files from list and commit them.

  • Publish branch (if it is first commit) or push them

Pulling changes

  • Pull refers to the process of retrieving the latest changes from a remote repository and merging them into your local repository.

Conflicts

  • Conflicts arise when simultaneous and not harmonious changes were made to the same part of a file by different branches or contributors.
  • Conflicts are flagged using special characters (<<<<<<====>>>>>>)
  • GitHub will not be able to publish or update your commit until you solve these conflicts.
  • Always make sure of fetching BEFORE commiting!!!
  • How can we handle them?


Branching

  • A branch is a lightweight movable pointer that represents an independent line of development.
  • You can isolate and work on different features within a repository without affecting the main code.
  • You can switch between branches at any time but commits are branch-specific.
  • Always make sure you are working on the desired one.
  • You can merge the progress on your branch to the main code once you finish experimenting on it.
  • How can we perform the branching?
  • Create and name a new branch
  • Publish your new branch

Pull Request

  • A pull request is a feature that allows to propose changes they’ve made in their branch to be reviewed and potentially merged into another branch.
  • A proper implementation of pull requests comes along with some benefits:
    • Facilitates code reviewing
    • Allows a smoother collaboration
    • Continous Integration
  • Submit a Pull Request to merge your changes into the main code.
  • If conflicts arise, you will need to resolve them.
  • Resolve the conflicts
  • Review and approve changes if necessary.

Stata & Git implementation

Updating branches

Thank you for your attention